﻿using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using YJKRevitCode.ElmentSearchUtility.LinkDocumentSuite;
using YJKRGeometry;
using SectionSignAndFilled.StairsRoomSection.DataDefine;
using SectionSignAndFilled.StairsRoomSection.Kit;

namespace SectionSignAndFilled.StairsRoomSection.SignElems
{
	public class LevelSign
	{
		public LevelSign(SectionViewData viewdata, Line baseLine, List<BaseLinkDocumentResultBean> lstLevel)
		{
			this.m_secData = viewdata.clone();
			this.m_Doc = viewdata.SectionView.Document;
			this.m_BaseLine = baseLine;
			this.m_listLevel = new List<BaseLinkDocumentResultBean>();
			this.m_listLevel.AddRange(lstLevel);
		}

		public bool Sign()
		{
			if (this.m_listLevel.Count < 2)
			{
				return true;
			}
            //from a in this.m_listLevel
            //orderby (a.UseElement as Level).Elevation
            //select a;
			List<double> list = new List<double>();
			foreach (BaseLinkDocumentResultBean baseLinkDocumentResultBean in this.m_listLevel)
			{
				Level level = baseLinkDocumentResultBean.UseElement as Level;
				double elevation = level.Elevation;
				if (Geometry.LessThan(elevation, this.m_secData.MaxPt.Z) && Geometry.GreaterThan(elevation, this.m_secData.MinPt.Z))
				{
					double item = SignCommon.TransformDouble(baseLinkDocumentResultBean.GetTotalTransform(), elevation);
					list.Add(item);
				}
			}
			SignCommon.CreateDimByElevatorAndLine(this.m_Doc, list, this.m_BaseLine, this.m_secData.SectionView.RightDirection);
			return true;
		}

		private Line m_BaseLine;

		private Document m_Doc;

		private List<BaseLinkDocumentResultBean> m_listLevel;

		private SectionViewData m_secData;
	}
}
